// 错误处理
const errorHandler = async (ctx, next) => {
  try {
    await next()
  } catch (error) {
    ctx.status = error.status || error.statusCode
    ctx.body = {
      code: ctx.status,
      message: error.message
    }
  }
}

module.exports = {
  errorHandler
}
